<?php
	/**
	 * Created by PhpStorm.
	 * User: mybook-lhp
	 * Date: 18/4/12
	 * Time: 下午4:04
	 */

	namespace app\common\traits;


	use app\common\utils\UtilConfig;
	use app\common\utils\UtilFiles;

	trait path
	{

		public function getModelMenus($modules, $menu_type = '')
		{
			$app_paths = UtilFiles::getDir(APP_PATH);

			return UtilConfig::getConfigByFile($app_paths, $modules, $menu_type);
		}

		/**
		 * 合并商户后台菜单
		 * @param $ModelMenus
		 * @param $HomeMenus
		 * @return mixed
		 */
		public function seller_merge_menu($ModelMenus, $HomeMenus)
		{

			if (is_array($ModelMenus))
			{
				foreach ($ModelMenus as $modelMenu)
				{
					if (is_array($modelMenu))
					{
						if (isset($modelMenu[key($modelMenu)]))
						{
							$HomeMenus[key($modelMenu)] = $modelMenu[key($modelMenu)];
						}
					}

				}
			}

			return $HomeMenus;
		}

		/**
		 * 合并后台菜单
		 * @param $ModelMenus
		 * @param $HomeMenus
		 * @return mixed
		 */
		public function admin_merge_menu($ModelMenus, $HomeMenus)
		{
			//dump([$ModelMenus, $HomeMenus]);
			if (is_array($ModelMenus))
			{
				foreach ($ModelMenus as $key => $modelMenu)
				{

					if (isset($modelMenu[key($modelMenu)]))
					{


						//dump([$key, key($modelMenu), isset($HomeMenus[key($modelMenu)])?$HomeMenus[key($modelMenu)]:'' ]);
						$HomeMenus[key($modelMenu)] = $modelMenu[key($modelMenu)];
					}
				}
			}
			//dump($ModelMenus);
			//die;
			return $HomeMenus;
		}
	}